﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using BusinessCommon.Utilities;
using System.Drawing;

namespace CustomControlLibrary
{
    public partial class StmMessageListBox : UserControl
    {
        public StmMessageListBox()
        {
            InitializeComponent();
        }


        /// <summary>
        /// Hiển thị list box message
        /// </summary>
        /// <param name="lstCode">List Message</param>
        /// <param name="listBoxType">Kiểu SmEnum.MSG_BOX_TYPE</param>
        public void ShowMessage(List<string> lstMessage, SmEnum.MSG_BOX_TYPE listBoxType)
        {
            try
            {
                this.listBox.Items.Clear();

                if (listBoxType.Equals(SmEnum.MSG_BOX_TYPE.ERR))
                {
                    this.listBox.ForeColor = Color.Red;
                }
                else
                {
                    this.listBox.ForeColor = Color.Black;
                }

                foreach (var item in lstMessage)
                {
                    if (!String.IsNullOrEmpty(item))
                    {
                        this.listBox.Items.Add(item);
 
                    }
                }
                this.listBox.Visible = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                this.listBox.Items.Clear();
                this.listBox.Items.Add(ErrorProcessor.GetErrorMessage(ItemDefineIF.ERR_UNKNOW));
            }
        }

        /// <summary>
        /// Clear message box
        /// </summary>
        public void ClearMessage()
        {
            this.listBox.Items.Clear();
        }
    }
}
